#!/bin/bash

function set_parameters () {
    file=$1
    calj_nstep=`echo "$calj_traj_length / $calj_dt" | bc -l | cut -f 2 -d '=' | cut -f 1 -d '.'`
    calj_xtc_n=`echo "$calj_frame_feq / $calj_dt" | bc -l | cut -f 2 -d '=' | cut -f 1 -d '.'`
    calj_log_n=`echo "$calj_log_feq/$calj_dt" | bc -l | cut -f 2 -d '=' |cut -f 1 -d '.'`
    calj_ener_n=`echo "$calj_ener_feq/$calj_dt" | bc -l | cut -f 2 -d '=' |cut -f 1 -d '.'`
    calj_seed=`date +%s`
    sed -e "/^dt/s/=.*/= $calj_dt/g" $file |\
    sed -e "/^nstep/s/=.*/= $calj_nstep/g" |\
    sed -e "/^ld-seed/s/=.*/= $calj_seed/g" |\
    sed -e "/^gen_vel/s/=.*/= no/g" |\
    sed -e "/^nstlog/s/=.*/= $calj_log_n/g" |\
    sed -e "/^nstenergy/s/=.*/= $calj_ener_n/g" |\
    sed -e "/^nstxout/s/=.*/= 0/g" |\
    sed -e "/^xtc-grps/s/=.*/= C4/g" |\
    sed -e "/^bd-fric/s/=.*/= $calj_gamma/g" |\
    sed -e "/^userreal1/s/=.*/= $calj_meta_low/g" |\
    sed -e "/^userreal2/s/=.*/= $calj_meta_up/g" |\
    sed -e "/^nstxtcout/s/=.*/= $calj_xtc_n/g" > tmptmptmp.mdp
    mv -f tmptmptmp.mdp $file
}


